package com.wanli.agent.homepage;

import android.os.Bundle;
import android.widget.TextView;

import com.wanli.agent.R;
import com.wanli.agent.base.BaseActivity;
import com.wanli.agent.bean.QueryOrderListBean;
import com.wanli.agent.utils.DateTimeUtil;
import com.wanli.agent.utils.NumberFormatUtils;
import com.wanli.agent.widget.AppTitleBar;

import java.util.Date;

import butterknife.BindView;
import butterknife.ButterKnife;

public class TransactionQueryDetailsActivity extends BaseActivity {

    @BindView(R.id.title_bar)
    AppTitleBar titleBar;
    @BindView(R.id.tv_merchant_name)
    TextView tvMerchantName;
    @BindView(R.id.tv_store_name)
    TextView tvStoreName;
    @BindView(R.id.tv_store_no)
    TextView tvStoreNo;
    @BindView(R.id.tv_agent_name)
    TextView tvAgentName;
    @BindView(R.id.tv_order_no)
    TextView tvOrderNo;
    @BindView(R.id.tv_device_unify_type)
    TextView tvDeviceUnifyType;
    @BindView(R.id.tv_device_unify_no)
    TextView tvDeviceUnifyNo;
    @BindView(R.id.tv_tran_mode)
    TextView tvTranMode;
    @BindView(R.id.tv_order_fee)
    TextView tvOrderFee;
    @BindView(R.id.tv_into_time)
    TextView tvIntoTime;
    @BindView(R.id.tv_rate)
    TextView tvRate;
    @BindView(R.id.tv_create_time)
    TextView tvCreateTime;
    @BindView(R.id.tv_pay_time)
    TextView tvPayTime;
    @BindView(R.id.tv_pay_channel)
    TextView tvPayChannel;
    private QueryOrderListBean.DataBean.ItemListBean itemListBean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_transaction_query_details);
        ButterKnife.bind(this);
        initView();
    }

    public void initView() {
        itemListBean = (QueryOrderListBean.DataBean.ItemListBean) getIntent().getSerializableExtra("itemListBean");
        if (itemListBean != null) {
            tvMerchantName.setText(itemListBean.getMerchant_name());
            tvStoreName.setText(itemListBean.getStore_name());
            tvStoreNo.setText(itemListBean.getStore_no());
            tvAgentName.setText(itemListBean.getAgent_name());
            tvOrderNo.setText(itemListBean.getOrder_no());
            tvDeviceUnifyNo.setText(itemListBean.getDevice_unify_no());

            if (itemListBean.getDevice_unify_type() == 1) {
                tvDeviceUnifyType.setText("扫码盒");
            } else if (itemListBean.getDevice_unify_type() == 3) {
                tvDeviceUnifyType.setText("码牌");
            } else if (itemListBean.getDevice_unify_type() == 4) {
                tvDeviceUnifyType.setText("云音响");
            } else if (itemListBean.getDevice_unify_type() == 6) {
                tvDeviceUnifyType.setText("码牌音响");
            } else if (itemListBean.getDevice_unify_type() == 8) {
                tvDeviceUnifyType.setText("收款码");
            }
            if (itemListBean.getPay_category_id() == 0) {
                tvTranMode.setText("现金支付");
            } else if (itemListBean.getPay_category_id() == 1) {
                tvTranMode.setText("微信");
            } else if (itemListBean.getPay_category_id() == 2) {
                tvTranMode.setText("支付宝");
            } else if (itemListBean.getPay_category_id() == 3) {
                tvTranMode.setText("云闪付");
            } else if (itemListBean.getPay_category_id() == 5) {
                tvTranMode.setText("NFC");
            } else if (itemListBean.getPay_category_id() == 6) {
                tvTranMode.setText("刷卡");
            }
            String order_fee = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(itemListBean.getOrder_fee()) / 100);
            tvOrderFee.setText(order_fee + "元");
            tvIntoTime.setText(itemListBean.getReach_flag());
//            if (itemListBean.getIs_t0() == 0) {
//                tvIntoTime.setText("D0");
//            } else if (itemListBean.getIs_t0() == 1) {
//                tvIntoTime.setText("T1");
//            } else if (itemListBean.getIs_t0() == 3) {
//                tvIntoTime.setText("D1");
//            } else {
//                tvIntoTime.setText("");
//            }
            tvRate.setText("0." + itemListBean.getRate() + "%");
            tvCreateTime.setText(DateTimeUtil.format7(new Date(Long.parseLong(itemListBean.getCreate_time()) * 1000)));
            tvPayTime.setText(DateTimeUtil.format7(new Date(Long.parseLong(itemListBean.getPay_time()) * 1000)));
            if ("DianYinPay".equals(itemListBean.getChannel_name())) {
                tvPayChannel.setText("电银");
            } else if ("KaidianbaoPay".equals(itemListBean.getChannel_name())) {
                tvPayChannel.setText("开店宝");
            } else {
                tvPayChannel.setText("");
            }

        }
    }
}
